home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctjnv85.arc
/
AEM.ASC
< prev
next >
Wrap
Text File
|
1985-10-23
|
4KB
|
131 lines
10 '-----------------------------------
20 ' FRACTAL CURVES AEM
30 '-----------------------------------
40 CLS:SCREEN 1,1:OPTION BASE 1
50 KEY OFF:DEFINT I-N:PI=3.141593
60 LOCATE 12,17:PRINT "Wait..."
70 DIM NH(50),NV(50),ID(50)
80 NM=5000:DIM X(NM),Y(NM),IC(NM)
90 '----- INPUT PARAMETERS ------------
100 RESTORE 1040
110 READ NL,ND,YOX,SC,IP
120 FOR I=1 TO NL-1:READ NH(I):NEXT
130 FOR I=1 TO NL-1:READ NV(I):NEXT
140 FOR I=1 TO NL :READ ID(I):NEXT
150 '----- POSITION THE CURVE ---------
160 XMIN=.5-.5*SC:XMAX=.5+.5*SC
170 ON IP GOTO 190,200,210
180 PRINT "IP>3":END
190 YMAX=.36*SC:YMIN=-.36*SC:GOTO 220
200 YMAX=.54*SC:YMIN=-.18*SC:GOTO 220
210 YMAX=.6*SC :YMIN=-.12*SC
220 VIEW:WINDOW (XMIN,YMIN)-(XMAX,YMAX)
230 '----- INITIALIZE -----------------
240 DIM ICT(1):IC(1)=1:LAST=2
250 X(1)=0!:X(2)=1!:Y(1)=0!:Y(2)=0!
260 '----- MAIN ROUTINE ---------------
270 FOR LEVEL=1 TO 4:CLS
280 LOCATE 25,1:PRINT "LEVEL =";LEVEL;
290 NNEW=(LAST-1)*NL+1:GOSUB 430
300 GOSUB 500:LAST=NNEW
310 IF LEVEL<5 THEN GOSUB 720
320 '----- DRAW THE CURVE -------------
330 PSET (X(1),Y(1)):FOR IP=2 TO LAST
340 LINE -(X(IP),Y(IP)):NEXT IP
350 '----- CONTINUE? ------------------
360 LOCATE 1,1
370 PRINT "ENTER to continue";
380 I$=INKEY$:IF I$="" THEN 360
390 IF I$=CHR$(13) THEN NEXT LEVEL
400 END
410 '----- END PROGRAM ----------------
420 '----- EXPAND X AND Y ARRAYS ------
430 IF NNEW<NM THEN 450
440 PRINT "...... MEMORY OVERFLOW":END
450 PRINT "......";NNEW;"POINTS"
460 FOR I=1 TO LAST:IFROM=LAST-I+1
470 ITO=(IFROM-1)*NL+1:X(ITO)=X(IFROM)
480 Y(ITO)=Y(IFROM):NEXT I: RETURN
490 '----- GENERATING FUNCTION --------
500 FOR I=2 TO LAST:II=(I-2)*NL+1
510 XS=X(II):YS=Y(II) :XF=X(II+NL)
520 YF=Y(II+NL):GOSUB 930
530 DX=(XF-XS)/ND:DY=(YF-YS)/ND
540 D=SQR(DX^2+DY^2):S=SIN(T):C=COS(T)
550 FOR J=1 TO NL-1:K=II+J:L=NL-J
560 ON IC(I-1) GOTO 570,600,640,670
570 X(K)=(XS+DX*NH(J))-D*YOX*NV(J)*S
580 Y(K)=(YS+DY*NH(J))+D*YOX*NV(J)*C
590 GOTO 700
600 NDH=ND-NH(L)
610 X(K)=(XS+DX*NDH)+D*YOX*NV(L)*S
620 Y(K)=(YS+DY*NDH)-D*YOX*NV(L)*C
630 GOTO 700
640 X(K)=(XS+DX*NH(J))+D*YOX*NV(J)*S
650 Y(K)=(YS+DY*NH(J))-D*YOX*NV(J)*C
660 GOTO 700
670 NDH=ND-NH(L)
680 X(K)=(XS+DX*NDH)-D*YOX*NV(L)*S
690 Y(K)=(YS+DY*NDH)+D*YOX*NV(L)*C
700 NEXT J:NEXT I: RETURN
710 '----- EXPAND IC ARRAY ------------
720 NUM=NL^(LEVEL-1)
730 ERASE ICT: DIM ICT(NUM)
740 FOR I=1 TO NUM:ICT(I)=IC(I):NEXT
750 FOR I=1 TO NUM
760 ON ICT(I) GOTO 770,790,840,890
770 FOR J=1 TO NL:K=NL*(I-1)+J
780 IC(K)=ID(J):NEXT J: GOTO 910
790 FOR J=1 TO NL:K=NL*(I-1)+J
800 ON ID(NL-J+1) GOTO 810,810,820,820
810 IC(K)=3-ID(NL-J+1):GOTO 830
820 IC(K)=7-ID(NL-J+1)
830 NEXT J: GOTO 910
840 FOR J=1 TO NL:K=NL*(I-1)+J
850 ON ID(J) GOTO 860,860,870,870
860 IC(K)=ID(J)+2:GOTO 880
870 IC(K)=ID(J)-2
880 NEXT J: GOTO 910
890 FOR J=1 TO NL:K=NL*(I-1)+J
900 IC(K)=5-ID(NL-J+1):NEXT J
910 NEXT I: RETURN
920 '----- FIND ANGLE WRT +X AXIS -----
930 DX=XF-XS:DY=YF-YS
940 IF DX=0 THEN 990
950 T=ATN(DY/DX)
960 IF DX<0! THEN 1000
970 IF DY<0! THEN T=T+PI*2
980 GOTO 1010
990 T=PI/2:IF DY>=0! THEN 1010
1000 T=T+PI
1010 RETURN
1020 '----- DATA ----------------------
1030 ' SAUSAGE LINK
1040 DATA 8,4,1,1,1
1050 DATA 1,1,2,2,2,3,3
1060 DATA 0,1,1,0,-1,-1,0
1070 DATA 1,1,1,1,1,1,1,1
1080 ' PINWHEEL
1090 DATA 10,4,0.57735,1,1
1100 DATA 1,2,2,3,2,1,2,2,3
1110 DATA 1,0,2,1,0,-1,-2,0,-1
1120 DATA 1,1,1,1,1,1,1,1,1,1
1130 ' ARROWHEAD
1140 DATA 10,8,1.732051,1,1
1150 DATA 2,4,3,5,6,4,3,5,6
1160 DATA 0,0,1,1,0,0,-1,-1,0
1170 DATA 1,1,1,1,1,1,1,1,1
1180 ' HEXAGONAL CONNECTION
1190 DATA 10,8,1.732051,1,1
1200 DATA 2,3,5,6,4,2,3,5,6
1210 DATA 0,1,1,0,0,0,-1,-1,0
1220 DATA 1,1,1,1,1,1,1,1,1,1
1230 ' SHOGUN HELMET
1240 DATA 4,4,1.73205,1,2
1250 DATA 1,2,3,0,1,0,1,1,1,1
1260 ' MONKEY TREE
1270 DATA 7,6,1.732051,1.8,2
1280 DATA 1,2,4,5,2,4,1,2,2,1,0,0
1290 DATA 3,1,1,4,2,2,1
1300 '----- END DATA ------------------